from database.db import update_movie_category, get_uncate_movie, find_my_category, movieCol


def update_movie_main_category(movie):
    movie['main_category'] = 'tv'
    update_movie_category(movie)


def get_rj():
    return movieCol.find({'$and':[{'url':{'$regex': '/mj/'}},{'updated':0}]})


def update_uncate_movie_category():
    movies = get_rj()
    for movie in movies:
        print(movie)
        category = find_my_category(movie)
        if category:
            movie['category'] = category['category']
            update_movie_main_category(movie)



if __name__ == '__main__':
    # while movie:= get_movie_for_update_category():
    #     update_movie_main_category(movie)
    update_uncate_movie_category()